<?
if(! defined('BASEPATH') ){ exit('Unable to view file.'); }

if($_GET['a'] == "del" && $id != ""){
	$sql = $db->Query("SELECT id,user,points FROM `linkedin` WHERE `id`='".$id."' AND `user`='".$data['id']."'");
	$sit = $db->FetchArray($sql);
	if($sit['id'] > 0){
		$db->Query("UPDATE `users` SET `coins`=`coins`+'".$sit['points']."' WHERE `id`='".$sit['user']."'");
		$db->Query("DELETE FROM `linkedin` WHERE `id`='".$sit['id']."'");
		$db->Query("DELETE FROM `linked` WHERE `site_id`='".$sit['id']."'");
	}
}
?>
		<table class="datatable sortable selectable full">				
		<thead>
	<tr class="theader">
			<th><b>Title</b></th>			
			<th width="15px"><b>Active</b></th>			
			<th width="70px"><b>Coins</b></th>	
			<th width="10px"><b>Clicks</b></th>	
			<th width="7px"><b>CPC</b></th>		
			<th width="95px"><b>Edit</b></th>			
		</tr>
        </thead>
		<tbody>				
<?
  $sql = $db->Query("SELECT * FROM `linkedin` WHERE `user`='".$data['id']."' ORDER BY `visits` DESC");
  for($j=1; $site = $db->FetchArray($sql); $j++)
{
?>		
			<tr>
				<td><a href="<?=$site['site']?>" target="_blank"><?=truncate($site['title'], 57)?></a></td>				
				<td><?=(($site['active'] > 0 || $site['confirm'] > 0) ? '<font color="red">No' : '<font color="green">Yes')?></font></td>				
				<td><a href="addcoins.php?x=linkedin&id=<?=$site['id']?>"><?=$site['points']?></a></td>
				<td><?=$site['visits']?></td>	
				<td><?=$site['cpc']?></td>	
				<td><ul class="action-buttons">
                <li><a href="editurl.php?x=linkedin&id=<?=$site['id']?>" class="action-button" title="Edit URL"><span class="edit"></span></a></li>
				<li><a href="addcoins.php?x=linkedin&id=<?=$site['id']?>" class="action-button" title="Add Coins"><span class="add"></span></a></li>
				<li><a href="mysites.php?x=linkedin&a=del&id=<?=$site['id']?>" class="action-button" title="Delete Site"><span class="delete"></span></a></li>
				</ul></td>					
			</tr>
			<?}?>
		</tbody>
</table>	